package com.jiaai.push;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jiaai.push.api.IPushApi;
import com.jiaai.push.model.IPush;
import com.jiaai.util.RestResultGenerator;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2018/1/3.
 */
@RestController
@RequestMapping("/api/v1/admin/push")
public class pushController {

        @Reference
        private IPushApi iPushApi;

        @PostMapping("/add")
        public Object pushMessage(@RequestBody IPush iPush){
            iPushApi.add(iPush);
            return RestResultGenerator.genSuccessResult("添加成功");
        }

        @GetMapping("/all")
        public  Object pushAll(){
        Object list = iPushApi.pushAll(1);
        return  RestResultGenerator.genSuccessResult(list);
        }

        @PostMapping("/delete/{id}")
        public Object delete(@PathVariable Integer id){
                iPushApi.delete(id);
                return RestResultGenerator.genSuccessResult("删除成功");
        }

        @GetMapping("/applyPush")
        public Object applyPush(){
                Object list=iPushApi.applyPush(1);
                return RestResultGenerator.genSuccessResult(list);
        }

        @PostMapping("/applyPass/{id}")
        public Object applyPass(@PathVariable Integer id){
                iPushApi.applyPass(id);
                return RestResultGenerator.genSuccessResult("申请通过");
        }

        @PostMapping("/applyRefuse/{id}")
        public Object applyRefuse(@PathVariable Integer id){
                iPushApi.applyRefuse(id);
                return  RestResultGenerator.genSuccessResult("申请未通过");
        }

        @GetMapping("/checkPush")
        public Object checkPush(){
                Object list=iPushApi.checkPush(1);
                return RestResultGenerator.genSuccessResult(list);
        }

        @PostMapping("/upMessageId/{id}")
        public Object upMessageId(@PathVariable Integer id){
                iPushApi.upMessageId(id);
                return  RestResultGenerator.genSuccessResult("推送成功");
        }

        @GetMapping("/getMemCity")
        public Object getMemCity(){
                Object list = iPushApi.getMemCity();
                return  RestResultGenerator.genSuccessResult(list);
        }



}
